using System;
using System.Collections;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Serialization;
using UnityEngine.UI;

public class ClientUI : BaseUI
{
    public Text clientName;
    public Transform iconContent;
    public Text sayText;

    private string _iconName;
    private string _name;

    protected override void OnInit(params object[] args)
    {
        
    }

    protected override void OnDispose()
    {

    }

    protected override void OnOpen(params object[] args)
    {
        _iconName = (string)args[0];
        _name = (string)args[1];

        UpdateShow();
    }

    protected override void OnClose()
    {

    }

    public void UpdateShow()
    {
        //更新头像
        CloseAllBg();
        iconContent.Find(_iconName).gameObject.SetActive(true);

        //更新名称
        clientName.text = _name;
    }

    public IEnumerator PingJiaAct(EPingJia pingJia,UnityAction cb)
    {
        switch (pingJia)
        {
            case EPingJia.goushi:
                Say("狗屎。。。");
                break;
            case EPingJia.bad:
                Say("一言难尽");
                break;
            case EPingJia.good:
                Say("还不错");
                break;
            case EPingJia.best:
                Say("好吃到爆炸！！！");
                break;
            default:
                break;
        }

        yield return new WaitForSeconds(2);
        Say(null);
    }

    private void Say(string words)
    {
        if (words == null)
        {
            sayText.text = "";
        }
        
        sayText.text = words;
    }

    public void CloseAllBg()
    {
        for (int i = 0; i < iconContent.childCount; i++)
        {
            iconContent.GetChild(i).gameObject.SetActive(false);
        }
    }
}
